<template>
<div>
  <h1>展示</h1>
  <table  border="1" cellspacing="0" align="center">
    <tr>
      <td>商品id</td>
      <td>商品名称</td>
      <td>商品分类</td>
      <td>操作</td>
    </tr>
    <tr v-for="i in shops">
      <td>
        <input type="checkbox" v-model="idlist" :value="i.id">
        {{i.id}}
      </td>
      <td>{{i.shop}}</td>
      <td @click="tiao(i.fid)">{{i.fname}}</td>
      <td>
        <button @click="del(i.id)">删除</button>
      </td>
    </tr>
  </table>
  <button v-for="i in numm" @click="get_shops(i)">{{i}}</button>
  <button @click="duo">多删</button>
</div>
</template>

<script>
export default {
  name: "a",
  data(){
    return{
      shops:[],
      numm:0,
      idlist:[]
    }
  },
  methods:{
    //多删
    duo(){
      this.$axios.delete('admin/addfl?did='+this.idlist).then(res=>{
        if(res.data.code==200){
          alert('ok')
          this.get_shops(1)
        }else {
          alert('no')
        }
      })
    },
    get_shops(i){
      this.$axios.get('admin/addshop?cpage='+i).then(res=>{
        this.shops = res.data.list
        this.numm = res.data.numm
      })
    },
    tiao(fid){
      this.$router.push({path:'/bb',query:{'fid':fid}})
    },
    del(id){
      this.$axios.delete('admin/addshop?id='+id).then(res=>{
        if(res.data.code==200){
          alert('ok')
          this.get_shops(1)
        }else {
          alert('no')
        }
      })
    }
  },
  mounted() {
    this.get_shops(1)
  }
}
</script>

<style scoped>

</style>
